package com.atguigu.vod.Utils;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.profile.DefaultProfile;
import com.baomidou.mybatisplus.annotation.Version;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class ConstantVodUtils implements InitializingBean {
    @Value("${aliyun.vod.file.keyid}")
    private String keyid;

    @Value("${aliyun.vod.file.keysecret}")
    private String keysecet;
    @Value("${aliyun.vod.file.regionId}")
    private String regionId;

    public static String ACCESS_KEY_SECRET;
    public static String ACCESS_KEY_ID;
    public static String ACCESS_REGION_ID;

    @Override
    public void afterPropertiesSet() throws Exception {
        ACCESS_KEY_SECRET = keysecet;
        ACCESS_KEY_ID = keyid;
        ACCESS_REGION_ID = regionId;
    }

    public static DefaultAcsClient initClient(String regionId,String accessKeyId,String accessKeySecret){
        DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
        DefaultAcsClient client = new DefaultAcsClient(profile);
        return client;
    }
}
